package com.wn.controller;

import com.common.entity.PageParam;
import com.common.entity.Rsp;
import com.common.entity.TravelNotice;
import com.wn.service.TravelNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("notice")
public class TravelNoticeController {
    @Autowired
    TravelNoticeService travelNoticeService;

    @PostMapping("/addOne")
    public Rsp addOne(@RequestBody TravelNotice travelNotice){

        return travelNoticeService.addOne(travelNotice);
    }

    @PostMapping("/del")
    public Rsp delcontent(@RequestBody TravelNotice travelNotice){
        return travelNoticeService.deleteLogical(travelNotice);
    }

    @PostMapping("/updata")
    public Rsp updataContent(@RequestBody TravelNotice travelNotice){
        return travelNoticeService.update(travelNotice);
    }

    @PostMapping("/selectOne")
    public Rsp selectOne(String id){
        TravelNotice oneById = travelNoticeService.getOneById(id);
        if (StringUtils.isEmpty(oneById)){
            return Rsp.fail().msg("查找失败");
        }else {
            return Rsp.success(oneById);
        }
    }

    @PostMapping("/searchSomeByPage")
    public Rsp searchSomeByPage(@RequestBody PageParam<TravelNotice> pageParam){
        return Rsp.success(travelNoticeService.searchSomeByPage(pageParam));
    }
}
